<template>
  <div class="total-container">
    <div class="common-tab-box">
      <div
        class="tab"
        v-for="item in tabs"
        :class="{ 'active': currentSelectedId === item.id }"
        :key="item.id"
        @click="handleClick(item.id)"
      >
        {{ item.text }}
      </div>
    </div>
    <component :is="compName"></component>
  </div>
</template>
<script>
import tuorism from './tabComp/tuorism.vue'
import transportation from './tabComp/transportation.vue'
export default {
  data() {
    return {
      tabs: [
        { text: '旅游', id: 0, compName: 'tuorism' },
        { text: '交通', id: 1, compName: 'transportation' }
      ],
      currentSelectedId: 0,
      compName: 'tuorism'
    }
  },
  components: {
    tuorism,
    transportation
  },
  methods: {
    handleClick(id) {
      this.currentSelectedId = id
      this.compName = this.tabs[id].compName
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  height: 90%;
}
</style>
